#include "../inc/Chess/advisor.h"
#include <iostream>
using namespace std;

Advisor::Advisor(PieceType type, int row, int col, bool isRed)
    : Piece(type, row, col, isRed)
{
}

bool Advisor::is_valid_move(int to_row, int to_col, PieceType board[9][10])
{
    int row = position.first;
    int col = position.second;

    // 计算移动距离
    int row_diff = to_row - row;
    int col_diff = to_col - col;

    // 士斜线移动一格
    if (!(abs(row_diff) == 1 && abs(col_diff) == 1))
    {
        return false;
    }

    // 红方士的移动范围
    if (isRed)
    {
        if (to_col < 3 && (to_row <= 5 && to_row >= 3))
        {
            return true;
        }
    }
    else
    {
        if (to_col >= 7 && (to_row <= 5 && to_row >= 3))
        {
            return true;
        }
    }

    return false;
}